package com.sweet.pay.dto;

import com.sweet.pay.enums.TradeType;

import java.util.Map;

/**
 * Created by sweet on 2019/6/5.
 * ---------------------------
 */
public class WxPayResult {
  private String appId;

  private String mchId;

  private String nonceStr;

  private String sign;

  private String tradeType;

  private String prepayId;

  private String codeUrl;

  private Throwable throwable;

  public Throwable getThrowable() {
    return throwable;
  }

  public void setThrowable(Throwable throwable) {
    this.throwable = throwable;
  }

  public WxPayResult() {
  }

  @Override
  public String toString() {
    return "WxPayResult{" +
        "appId='" + appId + '\'' +
        ", mchId='" + mchId + '\'' +
        ", nonceStr='" + nonceStr + '\'' +
        ", sign='" + sign + '\'' +
        ", tradeType='" + tradeType + '\'' +
        ", prepayId='" + prepayId + '\'' +
        ", codeUrl='" + codeUrl + '\'' +
        ", throwable=" + throwable.getMessage() +
        '}';
  }

  public WxPayResult(Map<String, String> map, TradeType type) {
    this.appId = map.get("appid");
    this.mchId = map.get("mch_id");
    this.nonceStr = map.get("nonce_str");
    this.sign = map.get("sign");
    this.tradeType = map.get("trade_type");
    this.prepayId = map.get("prepay_id");
    this.codeUrl = TradeType.NATIVE == type ? map.get("code_url") : null;
  }

  public String getCodeUrl() {
    return codeUrl;
  }

  public void setCodeUrl(String codeUrl) {
    this.codeUrl = codeUrl;
  }

  public String getAppId() {
    return appId;
  }

  public void setAppId(String appId) {
    this.appId = appId;
  }

  public String getMchId() {
    return mchId;
  }

  public void setMchId(String mchId) {
    this.mchId = mchId;
  }

  public String getNonceStr() {
    return nonceStr;
  }

  public void setNonceStr(String nonceStr) {
    this.nonceStr = nonceStr;
  }

  public String getSign() {
    return sign;
  }

  public void setSign(String sign) {
    this.sign = sign;
  }

  public String getTradeType() {
    return tradeType;
  }

  public void setTradeType(String tradeType) {
    this.tradeType = tradeType;
  }

  public String getPrepayId() {
    return prepayId;
  }

  public void setPrepayId(String prepayId) {
    this.prepayId = prepayId;
  }
}
